package com.shujing.mapper;

import com.shujing.pojo.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 陈书憬
 * @version 1.0
 * 2024/4/8
 */
@Mapper
public interface CategoryMapper {

    /**
     * 查看是否存在该分类名称
     *
     * @param categoryName
     * @return
     */
    @Select("select * from category where category_name = #{categoryName}")
    String selectCategoryName(String categoryName);

    @Insert("insert into category (category_name, category_alias, create_user, create_time, update_time) " +
            "values (#{categoryName},#{categoryAlias},#{createUser},#{createTime},#{updateTime})")
    void insert(Category category);

    @Select("select * from category where create_user =#{userId}")
    List<Category> list(Integer userId);

    @Select("select * from category where id = #{id}")
    Category selectById(Number id);

    void update(Category category);

    @Delete("delete from category where id = #{id}")
    void delete(Integer id);
}
